from settings import data1_connection
from simulated_trading.model import strategy


class StrategyBacktest:

    def insert_strategy_backtest(self, strategy_name):
        """
        插入策略的hu8oce数据
        :param strategy_name:
        :return:
        """
        pass

    def select_strategy_backtest(self, strategy_name):
        """
        插入策略回测数据之前， 要先检查回测数据是否已已经存在
        :param strategy_name:
        :return:
        """
        cursor, conn = data1_connection()
        strategy_id = strategy.select_strategy(strategy_name)
        sql = "select id from strategy_netvalue where strategyId='%s'" % strategy_id
        try:
            cursor.execute(sql)
            conn.commit()
            pointer = cursor.fetchall()
            id = pointer[0]["id"]
            return id
        except Exception as e:
            conn.rollback()
            print(e)
            return False


strategy_backtest = StrategyBacktest()






